package com.jt.common.net;


import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class Tomcat {

    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(9999);
        System.out.println("服务已经启动...");
        while (true) {
            Socket socket = serverSocket.accept();
            OutputStream out = socket.getOutputStream();
            byte[] responseContent = ("HTTP/1.1 200 Ok \r\n"+
                    "Content-Type: text/html;charset=utf-8 \r\n" +
                    "\r\n"+
                    "<h2>hello client</h2>").getBytes(StandardCharsets.UTF_8);
            out.write(responseContent);
            out.flush();
        }


    }
}
